{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Linked Panning\n",
    "\n",
    "\"Linked Panning\" is the capability of updating multiple plot ranges simultaneously as a result of panning one plot. In Bokeh, linked panning is acheived by shared `x_range` and/or `y_range` values between plots. \n",
    "\n",
    "Exeute the cells below and pan the resulting plots. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from bokeh.io import output_notebook, show\n",
    "from bokeh.layouts import gridplot\n",
    "from bokeh.plotting import figure\n",
    "output_notebook()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "x = list(range(11))\n",
    "y0 = x\n",
    "y1 = [10-xx for xx in x]\n",
    "y2 = [abs(xx-5) for xx in x]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# create a new plot\n",
    "s1 = figure(width=250, plot_height=250, title=None)\n",
    "s1.circle(x, y0, size=10, color=\"navy\", alpha=0.5)\n",
    "\n",
    "# create a new plot and share both ranges\n",
    "s2 = figure(width=250, height=250, x_range=s1.x_range, y_range=s1.y_range, title=None)\n",
    "s2.triangle(x, y1, size=10, color=\"firebrick\", alpha=0.5)\n",
    "\n",
    "# create a new plot and share only one range\n",
    "s3 = figure(width=250, height=250, x_range=s1.x_range, title=None)\n",
    "s3.square(x, y2, size=10, color=\"olive\", alpha=0.5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "p = gridplot([[s1, s2, s3]], toolbar_location=None)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "show(p)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
